#include "../../libraries/sockets/udp_socket.h"

#include <iostream>

using namespace std; 

int main(int argc, char *argv[])

{
    if (argc<2){
        cout <<"use this format: ./server IP portno" <<endl;
        exit(1);
    }

    UDP_socket serverUDP;

    serverUDP.setPortno(atoi(argv[1]));

    serverUDP.bind();

    string message, response;

    while(1) //Se queda escuchando
    {

        serverUDP.read(message); // Para mostar que ambas formas son posibles. serverUDP>>message;

        serverUDP.setReceiverAdress();

        cout << "Client says: " << endl << message << endl;

        cout << "You write: " << endl;

        cin >> response;

        serverUDP.write(response); //serverUDP << response;

    }

    return 0;
}
